package com.atqinke.designpattern.behavioraltype.memo.whitebox;



/**
 * @BelongsProject: BasicConnection
 * @BelongsPackage: com.atqinke.designpattern.behavioraltype.memo.blackbox
 * @Author: NieHk
 * @CreateTime: 2022-08-29  18:15
 * @Description: 黑箱备忘录模式测试（备忘录中的接口都是不开放的）
 * @Version: 1.0
 */
public class test {
    public static void main(String[] args) {
        System.out.println("------------大战Boss前------------");
        //大战Boss前
        GameRole gameRole = new GameRole();
        gameRole.initState();
        gameRole.stateDisplay();

        //保存进度
        RoleStateCaretaker roleStateCaretaker = new RoleStateCaretaker();
        roleStateCaretaker.add("挑战boss前",gameRole.saveState());

        System.out.println("------------大战Boss二阶段后------------");
        //大战Boss时，损耗严重
        gameRole.fight(30,50,18);
        gameRole.stateDisplay();
        roleStateCaretaker.add("boss二阶段",gameRole.saveState());
        System.out.println("------------挑战boss失败------------");
        gameRole.fight(0,0,0);
        gameRole.stateDisplay();
        //恢复之前状态
        gameRole.recoverState("boss二阶段",roleStateCaretaker);
        gameRole.stateDisplay();
    }
}
